/**
 * fanjiao add
 * 主要用于组织管理模块、用户管理等管理员角色使用模块的相关接口请求
 *
 */
import { axios } from '@/utils/request'
import $notification from 'ant-design-vue/es/notification'
// const api = {

// }
// export default api
/**
 * 公共方法
 */
export function query (url, method, parameter, data) {
  return axios({
    url: url,
    method: method,
    params: parameter,
    data: data
  }).then(res => {
    if (res.status === 200) {
      return res
    } else {
      $notification['error']({
        message: res.message,
        duration: 4
      })
    }
  }).catch(e =>
    $notification['error']({
      message: e.message,
      duration: 4
    })
  )
}
export function method (actionParam) {
  return axios({
    url: actionParam.url,
    method: actionParam.action,
    params: actionParam.parameter,
    data: actionParam.data
  }).then(res => {
    if (res.status === 200) {
      if (res.rel === false) {
        $notification['error']({
          message: res.message,
          duration: 4
        })
      } else {
        $notification['success']({
          message: actionParam.message,
          duration: 2
        })
      }
    } else {
      $notification['error']({
        message: res.message,
        duration: 4
      })
    }
  }).catch(e =>
    $notification['error']({
      message: e.message,
      duration: 4
    })
  )
}
